﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ExtendUserList.ascx.cs" Inherits="DMS.Web.Common.Controls.ExtendUserList" %>
<script language="javascript" type="text/javascript" src="/Resources/Scripts/Scripts.js"></script>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="diy" %>
<style type="text/css">
    #chkSelector, #radSelector
    {
        border-width: 0px;
    }
</style>
<asp:UpdatePanel ID="up_UserList" runat="server">
    <ContentTemplate>
        <%--搜索栏--%>
        <div id="dvSearch" runat="server" class="search">
            <!----------- 查询信息 ------------------>
            <table width="100%" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="ico">
                        <a href="javascript:changeView('1')">
                            <img src="/themes/default/ico_have.gif" id="ico_1" border="0"></a>
                    </td>
                    <td class="form">
                        <table cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                                <th style="width:30px">
                                    <nobr>
                                        姓名：
                                    </nobr>
                                </th>
                                <td>
                                    <asp:TextBox ID="txtUserName" runat="server" Width="55px"></asp:TextBox>
                                </td>
                                <%--<th>
                                    <nobr>
                                        登录帐号：
                                    </nobr>
                                </th>
                                <td>
                                    <asp:TextBox ID="txtLoginID" runat="server" Width="80px"></asp:TextBox>
                                </td>--%>
                                 <th>
                                        <nobr>
                                            移动电话：
                                        </nobr>
                                    </th>
                                    <td>
                                        <asp:TextBox ID="txtMobile" runat="server" Width="80px"></asp:TextBox>
                                    </td>
                                <th>
                                    <nobr>
                                        所属部门：
                                    </nobr>
                                </th>
                                <td>
                                    <nobr>
                                        <asp:TextBox ID="txtDeptName" runat="server" Width="80px" ReadOnly="true" ToolTip="请在左侧组织架构中选择"></asp:TextBox>
                                        <input type="hidden" id="hidDeptID" runat="server" />
                                        <img id="imgSelectDept" runat="server" CanDisplay="NoDisplay" title="选择部门" src="/Resources/Images/icon_dept.gif" onclick="javascript:" />
                                    </nobr>
                                </td>
                                <td class="button" colspan=2 style="width:180px">
                                    <div style="float:right">
                                        <asp:LinkButton ID="btnQuery" CssClass="linkbtn" runat="server" OnClick="btnQuery_Click"><span>查&nbsp;询</span></asp:LinkButton>
                                        <asp:LinkButton ID="LinkButton1" CssClass="linkbtn" runat="server" OnClientClick="AddExtendUser()"><span>新&nbsp;增</span></asp:LinkButton>
                                        <asp:LinkButton ID="LinkButton2" CssClass="linkbtn" runat="server" OnClientClick="BatchAddExtendUser()"><span>导&nbsp;入</span></asp:LinkButton>
                                        <%--<asp:LinkButton ID="btnSync" CssClass="linkbtn" runat="server" OnClick="btnSync_Click" OnClientClick="javascript:return Warming();" ><span>同&nbsp;步</span></asp:LinkButton>--%>
                                   </div>
                                </td>
                            </tr>
                            <tbody id="div_1" style="display: none; border: 0px;">
                                <tr>
                                    <th>
                                        <nobr>
                                            性别：
                                        </nobr>
                                    </th>
                                    <td>
                                        <asp:DropDownList ID="ddlSex" runat="server" Width="65px">
                                            <asp:ListItem Value="1" Text="男"></asp:ListItem>
                                            <asp:ListItem Value="2" Text="女"></asp:ListItem>
                                            <asp:ListItem Value="3" Text="未知"></asp:ListItem>
                                            <asp:ListItem Value="ALL" Text="不限" Selected="True"></asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                    <th>
                                        <nobr>
                                            含子部门：
                                        </nobr>
                                    </th>
                                    <td>
                                        <asp:DropDownList ID="ddlContainSub" runat="server" Width="85px">
                                            <asp:ListItem Value="1" Text="包括" Selected="True"></asp:ListItem>
                                            <asp:ListItem Value="0" Text="不包括"></asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                    <%--<td align="left" colspan="2">
                                        <nobr>
                                            临时用户：
                                            <asp:DropDownList ID="ddlTempUser" runat="server" Width="50px">
                                                <asp:ListItem Value="1" Text="包括" Selected="True"></asp:ListItem>
                                                <asp:ListItem Value="0" Text="不包括"></asp:ListItem>
                                            </asp:DropDownList>
                                        </nobr>
                                    </td>--%>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </table>
        </div>
        <%--数据列表--%>
        <asp:DataGrid ID="dgUserList" runat="server" AutoGenerateColumns="false" Width="100%"
            CssClass="dg_borderstyle" OnItemDataBound="dgUserList_ItemDataBound">
            <HeaderStyle HorizontalAlign="Center" />
            <ItemStyle CssClass="dg_itemstyle" />
            <AlternatingItemStyle CssClass="dg_alternatingitemstyle" />
            <Columns>
                <asp:TemplateColumn HeaderText="多选" Visible="false">
                    <ItemStyle Width="30px" HorizontalAlign="Center" />
                    <HeaderTemplate>
                        <a id="selectAllLink" href="javascript:" title="点击“全选”或“取消全选”" onclick="javascrpt:SelectAll(this, 'chkSelector');"
                            statue="false" style="cursor: hand;">全选</a>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <input type="checkbox" id="chkSelector" name="chkSelector" value="<%#Eval("ID") %>" onchange="javascript:return;UpdateChkStatue(this, 'selectAllLink');" />
                    </ItemTemplate>
                </asp:TemplateColumn>
                <asp:TemplateColumn HeaderText="单选" Visible="false">
                    <ItemStyle Width="30px" HorizontalAlign="Center" />
                    <HeaderTemplate>
                        选择
                    </HeaderTemplate>
                    <ItemTemplate>
                        <input type="radio" id="radSelector" name="radSelector" value="<%#Eval("ID") %>" onclick="javascript:Clear();AddItem('<%#Eval("Name") %>（<asp:Literal ID="ltlDeptFullName" runat="server"></asp:Literal>）','<Actor Type=\'<%#Eval("ActorType") %>\' ID=\'<%#Eval("ID") %>\' LoginID=\'<%#Eval("LoginID") %>\' Name=\'<%#Eval("Name") %>\' DeptID=\'<%#Eval("Dept.ID") %>\' DeptName=\'<%#Eval("Dept.Name") %>\' Mobile=\'<%#Eval("Mobile") %>\'/>');" />
                        
                    </ItemTemplate>
                </asp:TemplateColumn>
                <asp:TemplateColumn HeaderText="姓名">
                    <ItemStyle Width="100px" />
                    <ItemTemplate>
                        <div title="<%#Eval("Name") %>" style="overflow: hidden; text-overflow: ellipsis; width: 100px;">
                            <nobr>
                                <a id="A2" href="#" onclick="ViewExtendUser('<%#Eval("ID")%>')"><%#Eval("Name") %></a>
                            </nobr>
                        </div>
                    </ItemTemplate>
                </asp:TemplateColumn>
               
                <asp:TemplateColumn HeaderText="性别">
                    <ItemStyle Width="50px" HorizontalAlign="Center" />
                    <ItemTemplate>
                        <div style="overflow: hidden; text-overflow: ellipsis; width: 50px;">
                            <nobr>
                                <asp:Label ID="labUserSex" runat="server"></asp:Label>
                            </nobr>
                        </div>
                    </ItemTemplate>
                </asp:TemplateColumn>
                <asp:TemplateColumn HeaderText="职位描述">
                    <ItemStyle Width="150px" HorizontalAlign="Center" />
                    <ItemTemplate>
                        <div style="overflow: hidden; text-overflow: ellipsis; width: 150px;">
                            <nobr>
                                <asp:Label ID="labUserPosition" runat="server"></asp:Label>
                            </nobr>
                        </div>
                    </ItemTemplate>
                </asp:TemplateColumn>
                <asp:TemplateColumn HeaderText="所属部门">
                    <ItemStyle Width="150px" />
                    <ItemTemplate>
                        <div style="overflow: hidden; text-overflow: ellipsis; width: 150px;">
                            <nobr>
                                <asp:Label ID="labUserDept" runat="server"></asp:Label>
                            </nobr>
                        </div>
                    </ItemTemplate>
                </asp:TemplateColumn>
                <asp:TemplateColumn HeaderText="移动电话">
                    <ItemStyle Width="85px" HorizontalAlign="Center" />
                    <ItemTemplate>
                        <div title="<%#Eval("Mobile")%>" style="overflow: hidden; text-overflow: ellipsis; width: 85px;">
                            <nobr>
                                <%#Eval("Mobile")%>
                            </nobr>
                        </div>
                    </ItemTemplate>
                </asp:TemplateColumn>
                 <asp:TemplateColumn HeaderText="操作" Visible="false">
                    <ItemStyle HorizontalAlign="Center" />
                    <ItemTemplate>
                        <nobr>
                            <a id="A2" href="#" onclick="ViewExtendUser('<%#Eval("ID")%>')">查看</a>
                            <a id="A1" href="#" onclick="EditExtendUser('<%#Eval("ID")%>')">编辑</a>
                            <%--<a id="lkSelectBtn" runat="server" href="javascript:">删除</a>--%>
                        </nobr>
                    </ItemTemplate>
                </asp:TemplateColumn>
            </Columns>
        </asp:DataGrid>
        <div id="dvPager" class="PagerHolder">
        <diy:AspNetPager ID="pager" runat="server" AlwaysShow="true" OnPageChanged="pager_PageChanged"
            Width="100%" ShowPageIndexBox="Always" PageIndexBoxType="TextBox" TextBeforePageIndexBox="转到"
            TextAfterPageIndexBox="页" ShowCustomInfoSection="Left" CustomInfoHTML="总数：%RecordCount%，共 %PageCount% 页，当前为第%CurrentPageIndex%页"
            HorizontalAlign="right" FirstPageText="首页" PrevPageText="上页" NextPageText="下页"
            LastPageText="末页" CssClass="dg_pagestyle">
        </diy:AspNetPager>
        </div>
        <div id="dvEmpty" runat="server" class="EmptyMsg" visible="false">
            没有查询到相应的用户信息。
        </div>
        <asp:ListBox ID="lbGridColState" runat="server" Visible="false">
            <asp:ListItem Value="SingleSelector">1</asp:ListItem>
            <asp:ListItem Value="Management">7</asp:ListItem>
            <asp:ListItem Value="MutilSelector">8</asp:ListItem>
        </asp:ListBox>
    </ContentTemplate>
    <%--<Triggers>
        <asp:PostBackTrigger ControlID="btnSync" />
    </Triggers>--%>
</asp:UpdatePanel>
<div id="errorLabel"></div>
<script language="javascript" type="text/javascript">
<!--
    function Warming() {
        return window.confirm("用户同步操作需要较长，是否继续?");
    }
    var url = '/Modules/BaseSettings/ExtendUserView.aspx';
    function AddExtendUser(id) {
        var deptId = document.getElementById('<%=hidDeptID.ClientID %>').value;

        if (deptId == "" || deptId == null) {
            alert("请先选择部门。");
            return;
        } else {
            var result = window.showModalDialog(url + '?mode=new&categoryId='
                + document.getElementById('<%=hidDeptID.ClientID %>').value
                + '&deptName=' + encodeURI(document.getElementById('<%=txtDeptName.ClientID %>').value), null, "dialogHeight: 350px; dialogWidth: 650px; dialogTop: px; dialogLeft: px; edge:Raised; center: Yes; help: Yes; resizable: Yes; status: no;");
            if (result == "1") {
                window.location.reload();
            } 
         }
    }

    function BatchAddExtendUser(id) {

//            var fileInfo = OpenFileUploaderWithFile("第三方人员导入模板", "/Resources/Templates/第三方人员导入模板.xls"); //window.showModalDialog("/common/applicationpages/uploadfile.aspx", null, "dialogheight: 450px; dialogwidth: 650px; dialogtop: px; dialogleft: px; edge:raised; center: yes; help: yes; resizable: yes; status: no;");
            var fileInfo = "第三方人员导入模板_1.xls;Resources/Templates/第三方人员导入模板111.xls";
            if (!fileInfo)
                return;
            var now = new Date();
            var s = now.getSeconds();
            //alert(fileInfo);
            jQuery.ajax({
                type: "GET",
                url: "/Common/Services/ImportExtendUsers.aspx?fileInfo=" + encodeURI(fileInfo) +  "&s=" + s,
                dataType: "xml",
                success: function (xml) {
                    //alert(xml.xml);
                    //                    var parse = new XmlToTableParseHeji(xml, 'tb_MaterialList', rowTemplate, '', hd_selectedAssetsObj, GetSelectedMaterials, GetSelectedMaterials, true);

                    //                    parse.render('Asset'); //GetSelectedMaterials();
                    var errorText = $(xml).find("Error").text();
                    if (errorText && errorText != '') {
                        document.getElementById('errorLabel').innerHTML = errorText;
                        alert("导入失败，请检查错误信息！");
                    }
                    else {
                        document.getElementById('errorLabel').innerHTML = '';
                        alert("导入成功！");
                        window.location.reload();
                    }

                },
                error: function (a, b, c) { alert("导入文件不符合格式，请使用模板填写。"); }
            });
    }

    function EditExtendUser(id) {
        var result = window.showModalDialog(url + '?mode=edit&userid='+id, null, "dialogHeight: 350px; dialogWidth: 650px; dialogTop: px; dialogLeft: px; edge:Raised; center: Yes; help: Yes; resizable: Yes; status: no;");
        if (result == "1") {
            window.location.reload();
        }
    }

    function ViewExtendUser(id) {
        var result = window.showModalDialog(url + '?mode=view&userid=' + id, null, "dialogHeight: 350px; dialogWidth: 650px; dialogTop: px; dialogLeft: px; edge:Raised; center: Yes; help: Yes; resizable: Yes; status: no;");
    }
//-->
</script>